<%@page import="com.jsz.peini.common.util.PeiniUtils"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <meta charset="UTF-8">
	<title>Document</title>
	<meta name="viewport" content="initial-scale=1, width=device-width, maximum-scale=1, user-scalable=no">
	<meta content="telephone=no" name="format-detection" />
	<link rel="stylesheet" type="text/css" href="css/index.css">
	<link rel="stylesheet" type="text/css" href="css/store.css">
	<style>


    .opacity{
        -webkit-animation: opacity 0.3s linear;
        animation: opacity 0.3s linear;
    }
    @-webkit-keyframes opacity {
        0% {
            opacity:0;
        }
        100% {
            opacity:1;
        }
    }
    @keyframes opacity {
        0% {
            opacity:0;
        }
        100% {
            opacity:1;
        }
    }

    </style>
    <link rel="stylesheet" href=" dist/dropload.css">
	<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
	<script type="text/javascript">
	//localStorage.sellerId = "${sessionScope.sellerId}";
	//localStorage.imgHost = "${sessionScope.imgHost}";
	
	// 页数
    var page = 1;
    // 每页展示10个
    var size = 10;
    
    var status = 100;
    
	$(document).ready(function() {
		$(".nav ul li").click(function(event) {
			//status = $(this).index()-1;
			status = $(this).index();
			if(status == 0){
				status = 100;
			}
			/* if(status == 0){
				status = 1;
			}
			if(status == 1){
				status = 2;
			} */
			$(this).addClass('current').siblings('.nav ul li').removeClass('current');
			$.ajax({
                type: 'GET',
                url: 'seller/orderListJson?page=1&rows='+size+'&status='+status+'&sellerId='+localStorage.sellerId,
                dataType: 'json',
                success: function(data){
                    var result = '';
                    for(var i = 0; i < data.lists.length; i++){
                        result +=   '<li onclick="location.href=\'<%=path %>/seller/orderDetail?orderId='+data.lists[i].id+'\'">'
                        				+'<div class="d-num">'+data.lists[i].orderCode+''+'<span class="date">'+data.lists[i].orderTime+'</span>'+'</div>';
                        if(data.lists[i].otherId == ''){
                        	result +=   '<div class="d-con only">';
                        }else{
                        	result +=   '<div class="d-con double">';
                        }
                        
                        if(data.lists[i].otherBy != 2){
	                        result +=   '<div class="l-c">'+'<img src="'+data.lists[i].userImageHead+'" alt="">'+'<div class="name">'+'<p class="m-nam">'+data.lists[i].userNickname+'</p>';
	                        if(data.lists[i].otherBy == null || data.lists[i].otherBy == ''){
	                        	result +=   '<p class="m-py">到店买单</p>'; 
	                        }else if(data.lists[i].otherBy == 1){
	                        	result +=   '<p class="m-py">发起人买单</p>'; 
	                        }else if(data.lists[i].otherBy == 3){
	                        	result +=   '<p class="m-py">AA</p>'; 
	                        }
	                        if(data.lists[i].userOrderCode != ''){
	                        	result +=   '<p class="m-bill">'+data.lists[i].userOrderCode+'</p>';
	                        }else{
	                        	result +=   '<p class="m-bill"></p>';
	                        }
	                        
	                        
	                        result +=   '</div>'+'</div>';
                        }
                        
                        if(data.lists[i].otherId != '' && data.lists[i].otherBy != 1){
                        	result +=   '<div class="l-c">'+'<img src="'+data.lists[i].otherImageHead+'" alt="">'+'<div class="name">'+'<p class="m-nam">'+data.lists[i].otherNickname+'</p>';
                        	if(data.lists[i].otherBy == 2){
	                        	result +=   '<p class="m-py">接收人买单</p>'; 
	                        }else if(data.lists[i].otherBy == 3){
	                        	result +=   '<p class="m-py">AA</p>'; 
	                        }
	                        if(data.lists[i].otherUserOrderCode != ''){
	                        	result +=   '<p class="m-bill">'+data.lists[i].otherUserOrderCode+'</p>';
	                        }else{
	                        	result +=   '<p class="m-bill"></p>';
	                        }
	                        //result +=   '<p class="m-bill">账单：'+data.lists[i].otherUserOrderCode+'</p>';
	                        result +=   '</div>'+'</div>';
                        }
                        
                        
                      //  result += '<div class="resu w-e">'+data.lists[i].orderStatus+'</div>';
                        if(data.lists[i].orderStatus == '待付款'){
                        		result += '<div class="resu w-p">待付款</div>';
                        }else if(data.lists[i].orderStatus == '待评价'){
                        		result += '<div class="resu w-e">待评价</div>';
                        }else if(data.lists[i].orderStatus == '已完成'){
                        		result += '<div class="resu ok-p">已完成</div>';
                        }else if(data.lists[i].orderStatus == '已取消'){
                        		result +='<div class="resu can-p">已取消</div>';	
                        }
                        result += '</div>';
                        result += '<div class="d-pri good"><span class="ori">总收入￥'+data.lists[i].payMoney+'</span></div>';
                        result +=   '</li>';
                    }
                    $('.lists').html(result);
                }
			})
		});
	});
	</script>
</head>
<body>
	<section class="nav">
	 	<div>
	 		<ul>
	 			<li class="current">全部</li>
	 			<li>待评价</li>
	 			<li>已完成</li>
	 			<!-- <li>待付款</li> -->
	 			<!-- <li>已取消</li> -->
	 		</ul>

	 		
	 	</div>
	 </section>
	<!-- <section class="do">
		<div><span class="mstat">店铺营业中</span><input type="button" value="" class="clo-btn "></div>
	</section> -->
	
	<c:choose>
		<c:when test="${fn:length(list) > 0 }">
			<section class="con-list">
			 	<div>
			 		<ul class="lists">
			 			<c:forEach items="${list }" var="info">
			 				<li onclick="location.href='<%=path %>/seller/orderDetail?orderId=${info.id }'">
				 				<div class="d-num">订单号：${info.orderCode } <span class="date"><fmt:formatDate value="${info.orderTime }" pattern="yyyy-MM-dd HH:mm" /></span></div>
				 				<c:choose>
				 					<c:when test="${info.otherId != null && info.otherId != '' }">
				 						<div class="d-con double">  
				 					</c:when>
				 					<c:otherwise>
				 						<div class="d-con only">
				 					</c:otherwise>
				 				</c:choose>
				 				<c:if test="${info.otherBy != 2}">
				 					<div class="l-c">
		                                <img src="${info.userImageHead}" alt="">
					 					<div class="name">
					 						<p class="m-nam">${info.userNickname }</p>
					 						<c:choose>
					 							<c:when test="${info.otherBy == null }">
					 								<p class="m-py">到店买单</p>
					 							</c:when>
					 							<c:when test="${info.otherBy == 1 }">
					 								<p class="m-py">发起人买单</p>
					 							</c:when>
					 							<c:when test="${info.otherBy == 3 }">
					 								<p class="m-py">AA</p>
					 							</c:when>
					 						</c:choose>
					 						
					 						<p class="m-bill">${info.userOrderCode }</p>
					 					</div>
				 					</div>
				 					</c:if>
				 					<c:if test="${info.otherId != null && info.otherBy != 1}">
				 						<div class="l-c">
					 						<img src="${info.otherImageHead}" alt="">
						 					<div class="name">
						 						<p class="m-nam">${info.otherNickname }</p>
						 						<c:choose>
						 							<c:when test="${info.otherBy == 2 }">
						 								<p class="m-py">接收人买单</p>
						 							</c:when>
						 							<c:when test="${info.otherBy == 3 }">
						 								<p class="m-py">AA</p>
						 							</c:when>
						 						</c:choose>
						 						<p class="m-bill">${info.otherUserOrderCode }</p>
						 					</div>
					 					</div>
				 					</c:if>
			 						<c:choose>
			 							<c:when test="${info.orderStatus == 0 }">
			 								<div class="resu w-p">
			 									待付款
			 								</div>
			 							</c:when>
			 							<c:when test="${info.orderStatus == 1 }">
			 								<div class="resu w-e">
			 									待评价
			 								</div>
			 							</c:when>
			 							<c:when test="${info.orderStatus == 2 }">
			 								<div class="resu ok-p">
			 									已完成
			 								</div>
			 							</c:when>
			 							<c:when test="${info.orderStatus == -1 }">
			 								<div class="resu can-p">
			 									已取消
			 								</div>
			 							</c:when>
			 						</c:choose>
				 				</div>
				 				<div class="d-pri good">  <!-- <span>8折</span> --> <span class="ori">总收入¥<fmt:formatNumber value="${info.payMoney/100 }" pattern="#.00"/></span></div>
				 			</li>
			 			</c:forEach>
			 		</ul>
			 	</div>
			 </section>
		</c:when>
		<c:otherwise>
			<section class="empty">
				<div>
					暂时没有订单
				</div>
			</section>
		</c:otherwise>
	</c:choose>
	
	 <section class="comb">
		<div>
			<p>确认关闭店铺</p>
			<ul>
				<li>
					<input type="button" value="确定" class="ok-btn">
				</li>
				<li>
					<input type="button" value="取消" class="can-btn">					
				</li>
			</ul>
		</div>
	</section>






	<script src="dist/dropload.min.js"></script>
	<script>
	$(function(){
	    // dropload
	    $('.con-list').dropload({
	        scrollArea : window,
	        domUp : {
	            domClass   : 'dropload-up',
	            domRefresh : '<div class="dropload-refresh">↓下拉刷新</div>',
	            domUpdate  : '<div class="dropload-update">↑释放更新</div>',
	            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>'
	        },
	        domDown : {
	            domClass   : 'dropload-down',
	            domRefresh : '<div class="dropload-refresh">↑上拉加载更多</div>',
	            domLoad    : '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
	            domNoData  : '<div class="dropload-noData">没有更多信息了</div>'
	        },
	        loadUpFn : function(me){
	            $.ajax({
	                type: 'GET',
	                url: 'seller/orderListJson?page=1&rows='+size+'&status='+status+'&sellerId='+localStorage.sellerId,
	                dataType: 'json',
	                success: function(data){
	                    var result = '';
	                    for(var i = 0; i < data.lists.length; i++){
	                        result +=   '<li onclick="location.href=\'<%=path %>/seller/orderDetail?orderId='+data.lists[i].id+'\'">'
	                        				+'<div class="d-num">'+data.lists[i].orderCode+''+'<span class="date">'+data.lists[i].orderTime+'</span>'+'</div>';
	                        if(data.lists[i].otherId == ''){
	                        	result +=   '<div class="d-con only">';
	                        }else{
	                        	result +=   '<div class="d-con double">';
	                        }
	                        
	                        if(data.lists[i].otherBy != 2){
	                        	result +=   '<div class="l-c">'+'<img src="'+data.lists[i].userImageHead+'" alt="">'+'<div class="name">'+'<p class="m-nam">'+data.lists[i].userNickname+'</p>';
		                        if(data.lists[i].otherBy == null || data.lists[i].otherBy == ''){
		                        	result +=   '<p class="m-py">到店买单</p>'; 
		                        }else if(data.lists[i].otherBy == 1){
		                        	result +=   '<p class="m-py">发起人买单</p>'; 
		                        }else if(data.lists[i].otherBy == 3){
		                        	result +=   '<p class="m-py">AA</p>'; 
		                        }
		                        if(data.lists[i].userOrderCode != ''){
		                        	result +=   '<p class="m-bill">'+data.lists[i].userOrderCode+'</p>';
		                        }else{
		                        	result +=   '<p class="m-bill"></p>';
		                        }
		                        
		                        result +=   '</div>'+'</div>';
	                        }
	                        if(data.lists[i].otherId != '' && data.lists[i].otherBy != 1){
	                        	result +=   '<div class="l-c">'+'<img src="'+data.lists[i].otherImageHead+'" alt="">'+'<div class="name">'+'<p class="m-nam">'+data.lists[i].otherNickname+'</p>';
	                        	if(data.lists[i].otherBy == 2){
		                        	result +=   '<p class="m-py">接收人买单</p>'; 
		                        }else if(data.lists[i].otherBy == 3){
		                        	result +=   '<p class="m-py">AA</p>'; 
		                        }
		                        if(data.lists[i].otherUserOrderCode != ''){
		                        	result +=   '<p class="m-bill">'+data.lists[i].otherUserOrderCode+'</p>';
		                        }else{
		                        	result +=   '<p class="m-bill"></p>';
		                        }
		                        //result +=   '<p class="m-bill">账单：'+data.lists[i].otherUserOrderCode+'</p>';
		                        result +=   '</div>'+'</div>';
	                        }
	                      //  result += '<div class="resu w-e">'+data.lists[i].orderStatus+'</div>';
	                      	if(data.lists[i].orderStatus == '待付款'){
                        		result += '<div class="resu w-p">待付款</div>';
                      	  	}else if(data.lists[i].orderStatus == '待评价'){
                        		result += '<div class="resu w-e">待评价</div>';
                       	 	}else if(data.lists[i].orderStatus == '已完成'){
                        		result += '<div class="resu ok-p">已完成</div>';
                      	  	}else if(data.lists[i].orderStatus == '已取消'){
                        		result +='<div class="resu can-p">已取消</div>';	
                     	   	}
	                        result += '</div>';
	                        result += '<div class="d-pri wei">   <span class="ori">总收入￥'+data.lists[i].payMoney+'</span></div>';
	                        result +=   '</li>';
	                    }
	                    //console.log('aaa',result);
	                    // 为了测试，延迟1秒加载
	                    setTimeout(function(){
	                        $('.lists').html(result);
	                        // 每次数据加载完，必须重置
	                        me.resetload();
	                        // 重置页数，重新获取loadDownFn的数据
	                        page = 1;
	                        // 解锁loadDownFn里锁定的情况
	                        me.unlock();
	                        me.noData(false);
	                    },1000);
	                } ,
	                error: function(xhr, type){
	                    alert(JSON.stringify(xhr));
	                    // 即使加载出错，也得重置
	                    me.resetload();
	                }
	            });
	        },
	        loadDownFn : function(me){
	        	page++;
	            // 拼接HTML
	            var result = '';
	            $.ajax({
	                type: 'GET',
	                url: 'seller/orderListJson?page='+page+'&rows='+size+'&status='+status+'&sellerId='+localStorage.sellerId,
	                dataType: 'json',
	                success: function(data){
	                    var arrLen = data.lists.length;
	                    if(arrLen > 0){
	                    	for(var i = 0; i < data.lists.length; i++){
		                        result +=   '<li onclick="location.href=\'<%=path %>/seller/orderDetail?orderId='+data.lists[i].id+'\'">'
		                        				+'<div class="d-num">'+data.lists[i].orderCode+''+'<span class="date">'+data.lists[i].orderTime+'</span>'+'</div>';
		                        if(data.lists[i].otherId == ''){
		                        	result +=   '<div class="d-con only">';
		                        }else{
		                        	result +=   '<div class="d-con double">';
		                        }
		                        
		                        if(data.lists[i].otherBy != 2){
			                        result +=   '<div class="l-c">'+'<img src="'+data.lists[i].userImageHead+'" alt="">'+'<div class="name">'+'<p class="m-nam">'+data.lists[i].userNickname+'</p>';
			                        if(data.lists[i].otherBy == null || data.lists[i].otherBy == ''){
			                        	result +=   '<p class="m-py">到店买单</p>'; 
			                        }else if(data.lists[i].otherBy == 1){
			                        	result +=   '<p class="m-py">发起人买单</p>'; 
			                        }else if(data.lists[i].otherBy == 3){
			                        	result +=   '<p class="m-py">AA</p>'; 
			                        }
			                        if(data.lists[i].userOrderCode != ''){
			                        	result +=   '<p class="m-bill">'+data.lists[i].userOrderCode+'</p>';
			                        }else{
			                        	result +=   '<p class="m-bill"></p>';
			                        }
			                        
			                        result +=   '</div>'+'</div>';
		                        }
		                        if(data.lists[i].otherId != '' && data.lists[i].otherBy != 1){
		                        	result +=   '<div class="l-c">'+'<img src="'+data.lists[i].otherImageHead+'" alt="">'+'<div class="name">'+'<p class="m-nam">'+data.lists[i].otherNickname+'</p>';
		                        	if(data.lists[i].otherBy == 2){
			                        	result +=   '<p class="m-py">接收人买单</p>'; 
			                        }else if(data.lists[i].otherBy == 3){
			                        	result +=   '<p class="m-py">AA</p>'; 
			                        }
			                        if(data.lists[i].otherUserOrderCode != ''){
			                        	result +=   '<p class="m-bill">'+data.lists[i].otherUserOrderCode+'</p>';
			                        }else{
			                        	result +=   '<p class="m-bill"></p>';
			                        }
			                        //result +=   '<p class="m-bill">账单：'+data.lists[i].otherUserOrderCode+'</p>';
			                        result +=   '</div>'+'</div>';
		                        }
		                       // result += '<div class="resu w-e">'+data.lists[i].orderStatus+'</div>';
		                        if(data.lists[i].orderStatus == '待付款'){
	                        		result += '<div class="resu w-p">待付款</div>';
	                      	  	}else if(data.lists[i].orderStatus == '待评价'){
	                        		result += '<div class="resu w-e">待评价</div>';
	                       	 	}else if(data.lists[i].orderStatus == '已完成'){
	                        		result += '<div class="resu ok-p">已完成</div>';
	                      	  	}else if(data.lists[i].orderStatus == '已取消'){
	                        		result +='<div class="resu can-p">已取消</div>';	
	                     	   	}
		                        result += '</div>';
		                        result += '<div class="d-pri wei"><span class="ori">总收入￥'+data.lists[i].payMoney+'</span></div>';
		                        result +=   '</li>';
		                    }
	                    // 如果没有数据
	                    }else{
	                        // 锁定
	                        me.lock();
	                        // 无数据
	                        me.noData();
	                    }
	                    // 为了测试，延迟1秒加载
	                    setTimeout(function(){
	                        // 插入数据到页面，放到最后面
	                        $('.lists').append(result);
	                        // 每次数据插入，必须重置
	                        me.resetload();
	                    },1000);
	                },
	                error: function(xhr, type){
	                    //alert('Ajax error!');
	                    // 即使加载出错，也得重置
	                    me.resetload();
	                }
	            });
	        },
	        threshold : 50
	    });
	
	});
	</script>
</body>
</html>
